﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using ProjectBase.Core;

namespace $safeprojectname$
{
    [JsonObject]
    public class ODataMessage
    {
        public ODataMessage(int? totalCount, IEnumerable<object> data, int? takeRows = null, int? skipRows = null)
        {
            Data = new DataSet(totalCount, data)
            {
                TakeRows = takeRows,
                SkipRows = skipRows,
            };
        }

        [JsonProperty(PropertyName = "d")]
        public DataSet Data { get; protected set; }

        [JsonObject]
        public class DataSet
        {
            public DataSet(int? totalCount, IEnumerable<object> data)
            {
                Results = data;
                Count = totalCount;
            }

            [JsonProperty(PropertyName = "__count", NullValueHandling = NullValueHandling.Ignore)]
            public int? Count { get; protected set; }
            [JsonProperty(PropertyName = "__skip", NullValueHandling = NullValueHandling.Ignore)]
            public int? SkipRows { get; set; }
            [JsonProperty(PropertyName = "__top", NullValueHandling = NullValueHandling.Ignore)]
            public int? TakeRows { get; set; }
            [JsonProperty(PropertyName = "results")]
            public IEnumerable<object> Results { get; protected set; }
        }
    }
}
